import os
import requests

hosts = os.getenv('SERVER_LIB_URL', "http://127.0.0.1:5000")


def checkIdCard(id_card):
    url = hosts + "/id_card/verify"
    params = {
        'idCardNo': id_card
    }
    # response = requests.get(url, params=params) 发送get请求

    response = requests.post(url, json=params)
    return response.status_code == 200 and response.json().get("data")["result"]


def checkBankCard(bank_card):
    url = hosts + "/bank/card_verify"

    params = {
        'bankCard': bank_card
    }
    response = requests.post(url, json=params)
    return response.status_code == 200 and response.json().get("data")["result"]


def checkMobile(mobile_no):
    url = hosts + "/mobile/check"

    params = {
        'mobileNo': mobile_no
    }

    response = requests.post(url, json=params)
    return response.status_code == 200 and response.json().get("data")["result"]


def verifyOrderPayment(order_no):
    url = hosts + "/bank/query"

    # 模拟向支付中心发送验证请求进行验证
    params = {"OrderNo": order_no}
    response = requests.post(url, json=params)
    return response
